import { ViewEvent } from "../../Const";
import BaseModule from "../BaseModule";
import MainView from "./MainView";

export default class MainModule extends BaseModule{
    private _view:MainView=null
    init():void{
        this.message.on(ViewEvent.SHOW_MAIN_VIEW,()=>{
            //console.log(this)
            if(this._view==null){
                this._view=new MainView()
                this._view.on('game_win',()=>{
                    this.message.send(ViewEvent.SHOW_WIN_DIALOG)
                })
                this._view.on('hit_enemy',()=>{
                    this.message.send(ViewEvent.INC_ENEMY_COUNT)
                })
            }
            this.main.addChild(this._view)
        })
    }
}